3.34 \(\int \frac{B \tan (c+d x)+C \tan ^2(c+d x)}{(a+b \tan (c+d x))^2} \, dx\)

Optimal. Leaf size=115 \[ \frac{a (b B-a C)}{b d \left (a^2+b^2\right ) (a+b \tan (c+d x))}-\frac{\left (a^2 B+2 a b C-b^2 B\right ) \log (a \cos (c+d x)+b \sin (c+d x))}{d \left (a^2+b^2\right )^2}+\frac{x \left (a^2 (-C)+2 a b B+b^2 C\right )}{\left (a^2+b^2\right )^2} \]

[Out]

((2*a*b*B - a^2*C + b^2*C)*x)/(a^2 + b^2)^2 - ((a^2*B - b^2*B + 2*a*b*C)*Log[a*Cos[c + d*x] + b*Sin[c + d*x]])
/((a^2 + b^2)^2*d) + (a*(b*B - a*C))/(b*(a^2 + b^2)*d*(a + b*Tan[c + d*x]))

________________________________________________________________________________________

Rubi [A]  time = 0.14657, antiderivative size = 115, normalized size of antiderivative = 1., number of steps used = 3, number of rules used = 3, integrand size = 32, \(\frac{\text{number of rules}}{\text{integrand size}}\) = 0.094, Rules used = {3628, 3531, 3530} \[ \frac{a (b B-a C)}{b d \left (a^2+b^2\right ) (a+b \tan (c+d x))}-\frac{\left (a^2 B+2 a b C-b^2 B\right ) \log (a \cos (c+d x)+b \sin (c+d x))}{d \left (a^2+b^2\right )^2}+\frac{x \left (a^2 (-C)+2 a b B+b^2 C\right )}{\left (a^2+b^2\right )^2} \]

Antiderivative was successfully verified.

[In]

Int[(B*Tan[c + d*x] + C*Tan[c + d*x]^2)/(a + b*Tan[c + d*x])^2,x]

[Out]

((2*a*b*B - a^2*C + b^2*C)*x)/(a^2 + b^2)^2 - ((a^2*B - b^2*B + 2*a*b*C)*Log[a*Cos[c + d*x] + b*Sin[c + d*x]])
/((a^2 + b^2)^2*d) + (a*(b*B - a*C))/(b*(a^2 + b^2)*d*(a + b*Tan[c + d*x]))

Rule 3628

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)] + (C_.)*tan[(e_.) + (f
_.)*(x_)]^2), x_Symbol] :> Simp[((A*b^2 - a*b*B + a^2*C)*(a + b*Tan[e + f*x])^(m + 1))/(b*f*(m + 1)*(a^2 + b^2
)), x] + Dist[1/(a^2 + b^2), Int[(a + b*Tan[e + f*x])^(m + 1)*Simp[b*B + a*(A - C) - (A*b - a*B - b*C)*Tan[e +
 f*x], x], x], x] /; FreeQ[{a, b, e, f, A, B, C}, x] && NeQ[A*b^2 - a*b*B + a^2*C, 0] && LtQ[m, -1] && NeQ[a^2
 + b^2, 0]

Rule 3531

Int[((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])/((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[((a*c +
 b*d)*x)/(a^2 + b^2), x] + Dist[(b*c - a*d)/(a^2 + b^2), Int[(b - a*Tan[e + f*x])/(a + b*Tan[e + f*x]), x], x]
 /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 0] && NeQ[a*c + b*d, 0]

Rule 3530

Int[((c_) + (d_.)*tan[(e_.) + (f_.)*(x_)])/((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Simp[(c*Log[Re
moveContent[a*Cos[e + f*x] + b*Sin[e + f*x], x]])/(b*f), x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d,
0] && NeQ[a^2 + b^2, 0] && EqQ[a*c + b*d, 0]

Rubi steps

\begin{align*} \int \frac{B \tan (c+d x)+C \tan ^2(c+d x)}{(a+b \tan (c+d x))^2} \, dx &=\frac{a (b B-a C)}{b \left (a^2+b^2\right ) d (a+b \tan (c+d x))}+\frac{\int \frac{b B-a C+(a B+b C) \tan (c+d x)}{a+b \tan (c+d x)} \, dx}{a^2+b^2}\\ &=\frac{\left (2 a b B-a^2 C+b^2 C\right ) x}{\left (a^2+b^2\right )^2}+\frac{a (b B-a C)}{b \left (a^2+b^2\right ) d (a+b \tan (c+d x))}-\frac{\left (a^2 B-b^2 B+2 a b C\right ) \int \frac{b-a \tan (c+d x)}{a+b \tan (c+d x)} \, dx}{\left (a^2+b^2\right )^2}\\ &=\frac{\left (2 a b B-a^2 C+b^2 C\right ) x}{\left (a^2+b^2\right )^2}-\frac{\left (a^2 B-b^2 B+2 a b C\right ) \log (a \cos (c+d x)+b \sin (c+d x))}{\left (a^2+b^2\right )^2 d}+\frac{a (b B-a C)}{b \left (a^2+b^2\right ) d (a+b \tan (c+d x))}\\ \end{align*}

Mathematica [C]  time = 2.02736, size = 140, normalized size = 1.22 \[ \frac{\frac{2 \left (\left (a^2 (-B)-2 a b C+b^2 B\right ) \log (a+b \tan (c+d x))-\frac{a \left (a^2+b^2\right ) (a C-b B)}{b (a+b \tan (c+d x))}\right )}{\left (a^2+b^2\right )^2}+\frac{(B+i C) \log (-\tan (c+d x)+i)}{(a+i b)^2}+\frac{(B-i C) \log (\tan (c+d x)+i)}{(a-i b)^2}}{2 d} \]

Antiderivative was successfully verified.

[In]

Integrate[(B*Tan[c + d*x] + C*Tan[c + d*x]^2)/(a + b*Tan[c + d*x])^2,x]

[Out]

(((B + I*C)*Log[I - Tan[c + d*x]])/(a + I*b)^2 + ((B - I*C)*Log[I + Tan[c + d*x]])/(a - I*b)^2 + (2*((-(a^2*B)
 + b^2*B - 2*a*b*C)*Log[a + b*Tan[c + d*x]] - (a*(a^2 + b^2)*(-(b*B) + a*C))/(b*(a + b*Tan[c + d*x]))))/(a^2 +
 b^2)^2)/(2*d)

________________________________________________________________________________________

Maple [B]  time = 0.042, size = 305, normalized size = 2.7 \begin{align*}{\frac{\ln \left ( 1+ \left ( \tan \left ( dx+c \right ) \right ) ^{2} \right ){a}^{2}B}{2\,d \left ({a}^{2}+{b}^{2} \right ) ^{2}}}-{\frac{\ln \left ( 1+ \left ( \tan \left ( dx+c \right ) \right ) ^{2} \right ){b}^{2}B}{2\,d \left ({a}^{2}+{b}^{2} \right ) ^{2}}}+{\frac{\ln \left ( 1+ \left ( \tan \left ( dx+c \right ) \right ) ^{2} \right ) Cab}{d \left ({a}^{2}+{b}^{2} \right ) ^{2}}}+2\,{\frac{B\arctan \left ( \tan \left ( dx+c \right ) \right ) ab}{d \left ({a}^{2}+{b}^{2} \right ) ^{2}}}-{\frac{C\arctan \left ( \tan \left ( dx+c \right ) \right ){a}^{2}}{d \left ({a}^{2}+{b}^{2} \right ) ^{2}}}+{\frac{C\arctan \left ( \tan \left ( dx+c \right ) \right ){b}^{2}}{d \left ({a}^{2}+{b}^{2} \right ) ^{2}}}+{\frac{aB}{d \left ({a}^{2}+{b}^{2} \right ) \left ( a+b\tan \left ( dx+c \right ) \right ) }}-{\frac{C{a}^{2}}{d \left ({a}^{2}+{b}^{2} \right ) b \left ( a+b\tan \left ( dx+c \right ) \right ) }}-{\frac{{a}^{2}\ln \left ( a+b\tan \left ( dx+c \right ) \right ) B}{d \left ({a}^{2}+{b}^{2} \right ) ^{2}}}+{\frac{\ln \left ( a+b\tan \left ( dx+c \right ) \right ){b}^{2}B}{d \left ({a}^{2}+{b}^{2} \right ) ^{2}}}-2\,{\frac{\ln \left ( a+b\tan \left ( dx+c \right ) \right ) Cab}{d \left ({a}^{2}+{b}^{2} \right ) ^{2}}} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((B*tan(d*x+c)+C*tan(d*x+c)^2)/(a+b*tan(d*x+c))^2,x)

[Out]

1/2/d/(a^2+b^2)^2*ln(1+tan(d*x+c)^2)*a^2*B-1/2/d/(a^2+b^2)^2*ln(1+tan(d*x+c)^2)*b^2*B+1/d/(a^2+b^2)^2*ln(1+tan
(d*x+c)^2)*C*a*b+2/d/(a^2+b^2)^2*B*arctan(tan(d*x+c))*a*b-1/d/(a^2+b^2)^2*C*arctan(tan(d*x+c))*a^2+1/d/(a^2+b^
2)^2*C*arctan(tan(d*x+c))*b^2+1/d*a/(a^2+b^2)/(a+b*tan(d*x+c))*B-1/d*a^2/(a^2+b^2)/b/(a+b*tan(d*x+c))*C-1/d*a^
2/(a^2+b^2)^2*ln(a+b*tan(d*x+c))*B+1/d/(a^2+b^2)^2*ln(a+b*tan(d*x+c))*b^2*B-2/d/(a^2+b^2)^2*ln(a+b*tan(d*x+c))
*C*a*b

________________________________________________________________________________________

Maxima [A]  time = 1.72621, size = 250, normalized size = 2.17 \begin{align*} -\frac{\frac{2 \,{\left (C a^{2} - 2 \, B a b - C b^{2}\right )}{\left (d x + c\right )}}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} + \frac{2 \,{\left (B a^{2} + 2 \, C a b - B b^{2}\right )} \log \left (b \tan \left (d x + c\right ) + a\right )}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} - \frac{{\left (B a^{2} + 2 \, C a b - B b^{2}\right )} \log \left (\tan \left (d x + c\right )^{2} + 1\right )}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} + \frac{2 \,{\left (C a^{2} - B a b\right )}}{a^{3} b + a b^{3} +{\left (a^{2} b^{2} + b^{4}\right )} \tan \left (d x + c\right )}}{2 \, d} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((B*tan(d*x+c)+C*tan(d*x+c)^2)/(a+b*tan(d*x+c))^2,x, algorithm="maxima")

[Out]

-1/2*(2*(C*a^2 - 2*B*a*b - C*b^2)*(d*x + c)/(a^4 + 2*a^2*b^2 + b^4) + 2*(B*a^2 + 2*C*a*b - B*b^2)*log(b*tan(d*
x + c) + a)/(a^4 + 2*a^2*b^2 + b^4) - (B*a^2 + 2*C*a*b - B*b^2)*log(tan(d*x + c)^2 + 1)/(a^4 + 2*a^2*b^2 + b^4
) + 2*(C*a^2 - B*a*b)/(a^3*b + a*b^3 + (a^2*b^2 + b^4)*tan(d*x + c)))/d

________________________________________________________________________________________

Fricas [A]  time = 1.13058, size = 490, normalized size = 4.26 \begin{align*} -\frac{2 \, C a^{2} b - 2 \, B a b^{2} + 2 \,{\left (C a^{3} - 2 \, B a^{2} b - C a b^{2}\right )} d x +{\left (B a^{3} + 2 \, C a^{2} b - B a b^{2} +{\left (B a^{2} b + 2 \, C a b^{2} - B b^{3}\right )} \tan \left (d x + c\right )\right )} \log \left (\frac{b^{2} \tan \left (d x + c\right )^{2} + 2 \, a b \tan \left (d x + c\right ) + a^{2}}{\tan \left (d x + c\right )^{2} + 1}\right ) - 2 \,{\left (C a^{3} - B a^{2} b -{\left (C a^{2} b - 2 \, B a b^{2} - C b^{3}\right )} d x\right )} \tan \left (d x + c\right )}{2 \,{\left ({\left (a^{4} b + 2 \, a^{2} b^{3} + b^{5}\right )} d \tan \left (d x + c\right ) +{\left (a^{5} + 2 \, a^{3} b^{2} + a b^{4}\right )} d\right )}} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((B*tan(d*x+c)+C*tan(d*x+c)^2)/(a+b*tan(d*x+c))^2,x, algorithm="fricas")

[Out]

-1/2*(2*C*a^2*b - 2*B*a*b^2 + 2*(C*a^3 - 2*B*a^2*b - C*a*b^2)*d*x + (B*a^3 + 2*C*a^2*b - B*a*b^2 + (B*a^2*b +
2*C*a*b^2 - B*b^3)*tan(d*x + c))*log((b^2*tan(d*x + c)^2 + 2*a*b*tan(d*x + c) + a^2)/(tan(d*x + c)^2 + 1)) - 2
*(C*a^3 - B*a^2*b - (C*a^2*b - 2*B*a*b^2 - C*b^3)*d*x)*tan(d*x + c))/((a^4*b + 2*a^2*b^3 + b^5)*d*tan(d*x + c)
 + (a^5 + 2*a^3*b^2 + a*b^4)*d)

________________________________________________________________________________________

Sympy [F(-2)]  time = 0., size = 0, normalized size = 0. \begin{align*} \text{Exception raised: AttributeError} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((B*tan(d*x+c)+C*tan(d*x+c)**2)/(a+b*tan(d*x+c))**2,x)

[Out]

Exception raised: AttributeError

________________________________________________________________________________________

Giac [B]  time = 1.65895, size = 325, normalized size = 2.83 \begin{align*} -\frac{\frac{2 \,{\left (C a^{2} - 2 \, B a b - C b^{2}\right )}{\left (d x + c\right )}}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} - \frac{{\left (B a^{2} + 2 \, C a b - B b^{2}\right )} \log \left (\tan \left (d x + c\right )^{2} + 1\right )}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} + \frac{2 \,{\left (B a^{2} b + 2 \, C a b^{2} - B b^{3}\right )} \log \left ({\left | b \tan \left (d x + c\right ) + a \right |}\right )}{a^{4} b + 2 \, a^{2} b^{3} + b^{5}} - \frac{2 \,{\left (B a^{2} b^{2} \tan \left (d x + c\right ) + 2 \, C a b^{3} \tan \left (d x + c\right ) - B b^{4} \tan \left (d x + c\right ) - C a^{4} + 2 \, B a^{3} b + C a^{2} b^{2}\right )}}{{\left (a^{4} b + 2 \, a^{2} b^{3} + b^{5}\right )}{\left (b \tan \left (d x + c\right ) + a\right )}}}{2 \, d} \end{align*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((B*tan(d*x+c)+C*tan(d*x+c)^2)/(a+b*tan(d*x+c))^2,x, algorithm="giac")

[Out]

-1/2*(2*(C*a^2 - 2*B*a*b - C*b^2)*(d*x + c)/(a^4 + 2*a^2*b^2 + b^4) - (B*a^2 + 2*C*a*b - B*b^2)*log(tan(d*x +
c)^2 + 1)/(a^4 + 2*a^2*b^2 + b^4) + 2*(B*a^2*b + 2*C*a*b^2 - B*b^3)*log(abs(b*tan(d*x + c) + a))/(a^4*b + 2*a^
2*b^3 + b^5) - 2*(B*a^2*b^2*tan(d*x + c) + 2*C*a*b^3*tan(d*x + c) - B*b^4*tan(d*x + c) - C*a^4 + 2*B*a^3*b + C
*a^2*b^2)/((a^4*b + 2*a^2*b^3 + b^5)*(b*tan(d*x + c) + a)))/d